package cn.org.custom.client.responseHandler;

import cn.org.custom.message.LoginResponseMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

import static cn.org.custom.client.constants.Constants.LOGIN;
import static cn.org.custom.client.constants.Constants.WAIT_FOR_LOGIN;


@Slf4j
public class LoginResponseMessageHandler extends SimpleChannelInboundHandler<LoginResponseMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, LoginResponseMessage loginResponseMessage) throws Exception {
        if (loginResponseMessage.isSuccess()) {
            // 如果登录成功
            LOGIN.set(true);
        }
        // 唤醒 system in 线程
        WAIT_FOR_LOGIN.countDown();
    }
}
